//
//  Answers.m
//  SOViewer
//
//  Created by Aliaksandr Zdanovich on 10/11/12.
//
//

#import "Answer.h"

@implementation Answer

@synthesize text,date,score,name,isAcceped;

-(id)initWithObj:(NSDictionary *)obj{
    self = [super init];
    NSDateFormatter *format = [[[NSDateFormatter alloc]init ]autorelease ];
    [format setDateStyle:NSDateFormatterMediumStyle];
    [format setTimeStyle:NSDateFormatterShortStyle];
    self.text = [obj objectForKey:@"body"];
    self.name = [[obj objectForKey:@"owner"] objectForKey:@"display_name"];
    self.date = [format stringFromDate:[NSDate dateWithTimeIntervalSince1970:[[obj objectForKey:@"creation_date"] doubleValue]]];
    self.score = [NSString stringWithFormat:@"%@",[obj objectForKey:@"score"]];
    self.isAcceped = [obj objectForKey:@"is_accepted"];
    return self;
}

+(Answer*) answerWithObj:(NSDictionary*)obj{
    return [[[Answer alloc]initWithObj:obj]autorelease];
}

@end
